package net.haiyue.api.repository;
import net.haiyue.api.entity.SelectInfo;
import net.haiyue.api.entity.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.Transient;
import javax.transaction.Transactional;
import java.util.List;

@Transactional
public interface UserRepository extends BaseRepository<User,Integer> {
    User findUserByEmail(String email);
    @Query(value = "SELECT DISTINCT id as value,name as label FROM user",nativeQuery = true)
    List<SelectInfo> selectUsers();

    @Query(value = "UPDATE USER SET is_admin=?2 WHERE id=?1", nativeQuery = true)
    @Modifying
    void  updateAdmin(Integer id,boolean value);
}
